<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.4.2">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"wrr123.github.io","root":"/","scheme":"Muse","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},"path":"search.json"};
  </script>

  <meta name="description" content="财务自由的一般定义是由资产产生的收入不少于生活开销。">
<meta property="og:type" content="article">
<meta property="og:title" content="复式记账">
<meta property="og:url" content="https://wrr123.github.io/2021/06/22/%E5%A4%8D%E5%BC%8F%E8%AE%B0%E8%B4%A6/index.html">
<meta property="og:site_name" content="一缕烟气">
<meta property="og:description" content="财务自由的一般定义是由资产产生的收入不少于生活开销。">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2021-06-22T02:00:48.000Z">
<meta property="article:modified_time" content="2022-02-18T02:52:04.537Z">
<meta property="article:author" content="田园隐士">
<meta property="article:tag" content="复式记账">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="https://wrr123.github.io/2021/06/22/%E5%A4%8D%E5%BC%8F%E8%AE%B0%E8%B4%A6/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>复式记账 | 一缕烟气</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

<style>mjx-container[jax="SVG"] {
  direction: ltr;
}

mjx-container[jax="SVG"] > svg {
  overflow: visible;
}

mjx-container[jax="SVG"][display="true"] {
  display: block;
  text-align: center;
  margin: 1em 0;
}

mjx-container[jax="SVG"][justify="left"] {
  text-align: left;
}

mjx-container[jax="SVG"][justify="right"] {
  text-align: right;
}

g[data-mml-node="merror"] > g {
  fill: red;
  stroke: red;
}

g[data-mml-node="merror"] > rect[data-background] {
  fill: yellow;
  stroke: none;
}

g[data-mml-node="mtable"] > line[data-line] {
  stroke-width: 70px;
  fill: none;
}

g[data-mml-node="mtable"] > rect[data-frame] {
  stroke-width: 70px;
  fill: none;
}

g[data-mml-node="mtable"] > .mjx-dashed {
  stroke-dasharray: 140;
}

g[data-mml-node="mtable"] > .mjx-dotted {
  stroke-linecap: round;
  stroke-dasharray: 0,140;
}

g[data-mml-node="mtable"] > svg {
  overflow: visible;
}

[jax="SVG"] mjx-tool {
  display: inline-block;
  position: relative;
  width: 0;
  height: 0;
}

[jax="SVG"] mjx-tool > mjx-tip {
  position: absolute;
  top: 0;
  left: 0;
}

mjx-tool > mjx-tip {
  display: inline-block;
  padding: .2em;
  border: 1px solid #888;
  font-size: 70%;
  background-color: #F8F8F8;
  color: black;
  box-shadow: 2px 2px 5px #AAAAAA;
}

g[data-mml-node="maction"][data-toggle] {
  cursor: pointer;
}

mjx-status {
  display: block;
  position: fixed;
  left: 1em;
  bottom: 1em;
  min-width: 25%;
  padding: .2em .4em;
  border: 1px solid #888;
  font-size: 90%;
  background-color: #F8F8F8;
  color: black;
}

foreignObject[data-mjx-xml] {
  font-family: initial;
  line-height: normal;
  overflow: visible;
}

.MathJax path {
  stroke-width: 3;
}

mjx-container[display="true"] {
  overflow: auto hidden;
}

mjx-container[display="true"] + br {
  display: none;
}
</style><link rel="alternate" href="/atom.xml" title="一缕烟气" type="application/atom+xml">
</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">一缕烟气</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">沧海月明珠有泪，蓝田日暖玉生烟</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a>

  </li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup">
        <div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div id="search-result">
  <div id="no-result">
    <i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>
  </div>
</div>

    </div>
  </div>

</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://wrr123.github.io/2021/06/22/%E5%A4%8D%E5%BC%8F%E8%AE%B0%E8%B4%A6/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="田园隐士">
      <meta itemprop="description" content="talk is cheap, show me the code">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="一缕烟气">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          复式记账
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-06-22 10:00:48" itemprop="dateCreated datePublished" datetime="2021-06-22T10:00:48+08:00">2021-06-22</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2022-02-18 10:52:04" itemprop="dateModified" datetime="2022-02-18T10:52:04+08:00">2022-02-18</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E5%A4%8D%E5%BC%8F%E8%AE%B0%E8%B4%A6/" itemprop="url" rel="index"><span itemprop="name">复式记账</span></a>
                </span>
            </span>

          
            <span class="post-meta-item" title="阅读次数" id="busuanzi_container_page_pv" style="display: none;">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span id="busuanzi_value_page_pv"></span>
            </span><br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="far fa-file-word"></i>
              </span>
                <span class="post-meta-item-text">本文字数：</span>
              <span>5.3k</span>
            </span>
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="far fa-clock"></i>
              </span>
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              <span>5 分钟</span>
            </span>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <p><span style="color:Chocolate;text-align:center;display:inline-block;width:100%;">财务自由的一般定义是由资产产生的收入不少于生活开销。
</span><br><span id="more"></span></p>
<h4 id="如何实现财务自由"><a href="#如何实现财务自由" class="headerlink" title="如何实现财务自由"></a>如何实现财务自由</h4><ol>
<li>对支出的预期</li>
<li>对资产和收入的了解</li>
<li>对寿命的期望</li>
</ol>
<h4 id="为什么要复式记账"><a href="#为什么要复式记账" class="headerlink" title="为什么要复式记账"></a>为什么要复式记账</h4><p>它的核心理念是账户之间的进出关系，要求所有的记录全部入账，它可以保证账目的完整性和一致性。</p>
<p>复式记账可以提供除了开支记录之外的损益表、资产负债表、现金流量表、试算平衡表等报表。</p>
<h4 id="如何复式记账"><a href="#如何复式记账" class="headerlink" title="如何复式记账"></a>如何复式记账</h4><h5 id="会计恒等式"><a href="#会计恒等式" class="headerlink" title="会计恒等式"></a>会计恒等式</h5><p>最基本的形式是：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">资产 = 负债 + 权益(净资产)</span><br></pre></td></tr></table></figure>
<p>理解的难点在于，会计学上的资产[Assets]和一般人对一个人富有程度的理解不太一样，因为资产是负债和权益的总和，负载(Liabilities)也是资产的一部分。</p>
<p><strong>更容易理解的部分</strong>其实是权益(Equity)，在个人理财的上下文中，又和净资产(Net Assets)是等价的，也就是经常说的 <strong>个人净值</strong>。净资产需要由总资产排除负债，<strong>一个人到底是否富有，看的是净资产，而不是资产。</strong></p>
<h4 id="使用BeanAccount"><a href="#使用BeanAccount" class="headerlink" title="使用BeanAccount"></a>使用BeanAccount</h4><h5 id="优点"><a href="#优点" class="headerlink" title="优点"></a>优点</h5><blockquote>
<ol>
<li>Beancount是一个开源工具，用Python实现的，可以本地运行。</li>
<li>账本是一套基于文本的语法，方便存储和管理，个人拥有全部的数据，还可以使用Git管理。</li>
<li>账本的语法很规范，也具备灵活度，像编程语言一样可以嵌套引入，也有语法高亮和代码检查工具。</li>
<li>有完整的命令行工具链和可视化工具fava，还有基于SQL的查询和报表生成。</li>
<li>没有预先定义的类别、货币等现实世界概念，可以轻松实现多币种记账，包括各种点数、虚拟货币。</li>
</ol>
</blockquote>
<h5 id="下载安装"><a href="#下载安装" class="headerlink" title="下载安装"></a>下载安装</h5><p>需要python3的环境。</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">pip install beancount fava</span><br></pre></td></tr></table></figure>
<h4 id="账户类别"><a href="#账户类别" class="headerlink" title="账户类别"></a>账户类别</h4><p>复式记账的最基本的特点就是以账户为核心，Beancount的系统整体上就是围绕账户来实现的。</p>
<p>五个分类：</p>
<ul>
<li><p>Assets 资产 正数或负数，记录现金、银行存款；</p>
<p>  正数表示资产增加了，负数表示资产减少了。</p>
</li>
<li><p>Liabilities 负债 正数或负数，记录信用卡、房贷、车贷等；</p>
<p>  正数表示负债减少了，负数表示负债增加了。</p>
</li>
<li><p>Equity 权限(净资产) <strong>负数</strong>，净资产，存放在记账开始前已经有的收益；</p>
</li>
<li><p>Expenses 支出 正数，记录各种消费等；</p>
</li>
<li><p>Income 收入 <strong>负数</strong>，记录工资、奖金等；</p>
</li>
</ul>
<blockquote>
<p>Beancount要求每个使用的账户必须声明开户时间，格式是<code>YYYY-mm-dd</code>。之后是关键词<code>open</code>，表示在这个日期开户（或者开始记账）。接下来是账户名称，格式用<code>:</code>隔开的树形语法，最后是（可以省略的）账户的货币种类。货币种类不需要事先定义，也没有系统内部的定义，一般来说我们使用三字母的货币代码，但其实可以用任何的名字（惟一的限制是大写字母和下划线）。我在这个例子中使用了<code>USD</code>、<code>JPY</code>、<code>CNY</code>、<code>CHF</code>四个货币，以及我自定义的<code>P_JAL</code>和<code>P_UA</code>表示不同航空公司的里程。</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">2019-01-01 open Assets:Cash:JPY JPY</span><br><span class="line">2019-01-01 open Assets:Cash:USD USD</span><br><span class="line">2019-01-01 open Assets:Bank:CH:UBS CHF</span><br><span class="line">2019-01-01 open Assets:Bank:CN:BoC CNY</span><br></pre></td></tr></table></figure>
</blockquote>
<h4 id="基本借贷记账"><a href="#基本借贷记账" class="headerlink" title="基本借贷记账"></a>基本借贷记账</h4><p>复式记账又叫做 <strong>借贷记账</strong>。之所以这么叫，因为每一条记录都至少有一条借记(Debit)和一条贷记(Credit)。</p>
<p>如：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">2019-01-01 * "日本航空" "纽约-东京"</span><br><span class="line">  Expenses:Transport:Airline 1000 USD</span><br><span class="line">  Liabilities:CreditCard:US:Discover -1000 USD</span><br></pre></td></tr></table></figure>
<p>Beancount基本的语法如下所示：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">YYYY-mm-dd * ["payee"] "description"</span><br><span class="line">  posting 1</span><br><span class="line">  posting 2</span><br><span class="line">  ...</span><br></pre></td></tr></table></figure>
<blockquote>
<p>第一行要有日期，接下来是<code>*</code>。收款者<code>payee</code>是可选的，如果<code>*</code>后面只有一个字符串，那就是省略了<code>payee</code>。从第二行开始，每一行开头空两个缩进，然后是账户名以及金额、货币。这里有一个要点：要保证所有条目的总和是0，否则就会出现<code>Transaction does not balance: (xxx USD)</code>这样的错误。这个要求很好理解，因为花出去的钱必须和账户上减少的钱一样，否则就是所谓的「账目不平」了。</p>
</blockquote>
<p><strong>所有Expenses类别的账户都是正数，所有Income类别的账户都是负数。</strong></p>
<p>这就是有些工具使用负数表示借记(Debit)，使用正数表示贷记(Credit)的结果。</p>
<p>简单来说，借记就是将账户上的资金移除，贷记就是增加账户的资金。同理，通常<code>Assets</code>是正数，<code>Liabilities</code>是负数。</p>
<h4 id="货币转换"><a href="#货币转换" class="headerlink" title="货币转换"></a>货币转换</h4><ol>
<li>使用<code>@</code>记录单位货币的转换价格</li>
<li>使用<code>@@</code>记录转换后的金额</li>
</ol>
<h4 id="借贷管理"><a href="#借贷管理" class="headerlink" title="借贷管理"></a>借贷管理</h4><p>复式记账的强大之处是每个账户都有状态，而且每个操作都是原子的，这对复杂的资产进出记录非常有帮助。</p>
<h4 id="对账"><a href="#对账" class="headerlink" title="对账"></a>对账</h4><h5 id="资产负载表"><a href="#资产负载表" class="headerlink" title="资产负载表"></a>资产负载表</h5><p>所谓对账，就是看每个账户的结余(Balance)是否正确。每个账户的余额可以在资产负载表(Balance Sheet)页面中找到。</p>
<h5 id="结余断言-Balance-Assertion"><a href="#结余断言-Balance-Assertion" class="headerlink" title="结余断言(Balance Assertion)"></a>结余断言(Balance Assertion)</h5><p>例子:</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">2017-08-20 balance Assets:US:BofA:Checking 2298.50 USD</span><br></pre></td></tr></table></figure>
<h4 id="项目管理"><a href="#项目管理" class="headerlink" title="项目管理"></a>项目管理</h4><h5 id="版本管理"><a href="#版本管理" class="headerlink" title="版本管理"></a>版本管理</h5><ul>
<li>git</li>
</ul>
<h5 id="标签"><a href="#标签" class="headerlink" title="标签"></a>标签</h5><p>标签是一个将交易组织归类的方法，是开支类别之外的另一个维度。每个交易都能加上一个或多个标签。</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">2019-06-01 * "奥地利航空" "东京-维也纳" #2019-07-Europe-Trip</span><br><span class="line">  Expenses:Transport:Airline 600 USD</span><br><span class="line">  Liabilities:US:CreditCard:Citi</span><br></pre></td></tr></table></figure>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">pushtag #2019-07-Europe-Trip</span><br><span class="line"></span><br><span class="line">2019-06-01 * "奥地利航空" "东京-维也纳"</span><br><span class="line">  Expenses:Transport:Airline 600 USD</span><br><span class="line">  Liabilities:US:CreditCard:Citi</span><br><span class="line"></span><br><span class="line">2019-06-01 * "奥地利航空" "维也纳-莫斯科"</span><br><span class="line">  Expenses:Transport:Airline 100 USD</span><br><span class="line">  Liabilities:US:CreditCard:Citi</span><br><span class="line"></span><br><span class="line">poptag #2019-07-Europe-Trip</span><br></pre></td></tr></table></figure>
<h5 id="链接"><a href="#链接" class="headerlink" title="链接"></a>链接</h5><p>语法<code>^</code></p>
<p>例子：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">2016-05-03 * "Chase" "取现" ^2016-05-overdraft</span><br><span class="line">  Assets:Bank:US:Chase:Checking -75 USD</span><br><span class="line">  Assets:Cash:USD 50 USD</span><br><span class="line">  Expenses:Finance:BankFee:Overdraft 25 USD</span><br><span class="line"></span><br><span class="line">2016-05-05 * "Chase" "还清欠款" ^2016-05-overdraft</span><br><span class="line">  Assets:Bank:US:Chase:Checking 25 USD</span><br><span class="line">  Assets:Bank:US:Chase:Saving</span><br></pre></td></tr></table></figure>
<h5 id="多文件组织"><a href="#多文件组织" class="headerlink" title="多文件组织"></a>多文件组织</h5><p><code>include</code>后面紧跟着要引入的文件，路径是相对于当前文件的。</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">; main.beancount</span><br><span class="line">include "accounts.beancount"</span><br><span class="line">include "categories.beancount"</span><br><span class="line">include "books/books.beancount"</span><br><span class="line"></span><br><span class="line">; books/books.beancount</span><br><span class="line">include "2016.beancount"</span><br><span class="line">include "2017.beancount"</span><br><span class="line">include "2018.beancount"</span><br><span class="line">include "2019.beancount"</span><br></pre></td></tr></table></figure>
<h4 id="账本划分"><a href="#账本划分" class="headerlink" title="账本划分"></a>账本划分</h4><ul>
<li><p>按日期划分</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">; 2019-07-Europe-Trip.beancount</span><br><span class="line">pushtag #2019-07-Europe-Trip</span><br><span class="line"></span><br><span class="line">2019-06-01 * "奥地利航空" "东京-维也纳"</span><br><span class="line">  Expenses:Transport:Airline 600 USD</span><br><span class="line">  Liabilities:US:CreditCard:Citi</span><br><span class="line"></span><br><span class="line">...</span><br><span class="line">poptag #2019-07-Europe-Trip</span><br></pre></td></tr></table></figure>
</li>
<li><p>按类别划分</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line">; Tokyo-Electric-Power.beancount</span><br><span class="line"></span><br><span class="line">2018-04-25 * "东京电力" "电费"</span><br><span class="line">  Expenses:Utility 4621 JPY</span><br><span class="line">  Liabilities:JP:PrestiaVisa</span><br><span class="line"></span><br><span class="line">2018-05-25 * "东京电力" "电费"</span><br><span class="line">  Expenses:Utility 4956 JPY</span><br><span class="line">  Liabilities:JP:PrestiaVisa</span><br><span class="line"></span><br><span class="line">2018-06-25 * "东京电力" "电费"</span><br><span class="line">  Expenses:Utility 6648 JPY</span><br><span class="line">  Liabilities:JP:PrestiaVisa</span><br><span class="line"></span><br><span class="line">2018-07-25 * "东京电力" "电费"</span><br><span class="line">  Expenses:Utility 9394 JPY</span><br><span class="line">  Liabilities:JP:PrestiaVisa</span><br></pre></td></tr></table></figure>
</li>
<li><p>按账户划分</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br></pre></td><td class="code"><pre><span class="line">; AmexSPG.beancount</span><br><span class="line">2019-02-01 * "American Express" "SPG年费"</span><br><span class="line">  Expenses:Finance:CreditCardFee 33480 JPY</span><br><span class="line">  Liabilities:JP:AmexSPG</span><br><span class="line"></span><br><span class="line">2019-02-01 * "American Express" "Amex SPG开卡奖励"</span><br><span class="line">  Assets:Points:US:Marriott 30000 P_MRT</span><br><span class="line">  Income:OpeningBonus</span><br><span class="line"></span><br><span class="line">2019-02-22 document Liabilities:JP:AmexSPG "AmexSPG/2019-02.pdf"</span><br><span class="line"></span><br><span class="line">2019-03-11 * "American Express" "2019年2月账单还款"</span><br><span class="line">  Assets:Bank:JP:SMBC -3254 JPY</span><br><span class="line">  Liabilities:JP:AmexSPG</span><br><span class="line"></span><br><span class="line">2019-03-22 document Liabilities:JP:AmexSPG "AmexSPG/2019-03.pdf"</span><br><span class="line"></span><br><span class="line">2019-04-10 * "American Express" "2019年3月账单还款"</span><br><span class="line">  Assets:Bank:JP:SMBC -63935 JPY</span><br><span class="line">  Liabilities:JP:AmexSPG</span><br><span class="line"></span><br><span class="line">2019-04-22 document Liabilities:JP:AmexSPG "AmexSPG/2019-04.pdf"</span><br><span class="line"></span><br><span class="line">2019-05-10 * "American Express" "2019年4月账单还款"</span><br><span class="line">  Assets:Bank:JP:SMBC -23718 JPY</span><br><span class="line">  Liabilities:JP:AmexSPG</span><br></pre></td></tr></table></figure>
</li>
</ul>
<blockquote>
<ul>
<li>如果该收支属于一个特别的事件，那么就将其加入这个事件对应的单独文件，例如<code>#2019-07-Europe-Trip</code>。</li>
<li>如果该收支是一个周期项目，但跟某个银行账户无关，则加入按类别划分的文件，例如水电费、房租、工资。</li>
<li>如果该收支跟某个银行账户紧密相关，则加入该账户对应的文化，例如银行手续费、信用卡还款、返现。</li>
<li>不属于以上情况，则加入按日期划分的文件</li>
</ul>
</blockquote>
<h4 id="创建账户和关闭账户"><a href="#创建账户和关闭账户" class="headerlink" title="创建账户和关闭账户"></a>创建账户和关闭账户</h4><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">开启日期 open 账户名 货币类型</span><br><span class="line">关闭日期 close 账户名</span><br></pre></td></tr></table></figure>
<h4 id="交易明细"><a href="#交易明细" class="headerlink" title="交易明细"></a>交易明细</h4><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">日期 * "交易方" "交易备注"</span><br><span class="line">    账户   金额 货币</span><br><span class="line">    账户   金额 货币</span><br></pre></td></tr></table></figure>
<blockquote>
<ul>
<li>* 号表示这笔交易是确定的，没有疑问。若是 ! 号，表示存疑，但一般用不上。</li>
<li>交易方和交易备注，均可省略。</li>
<li>货币必须与账户设置中对应的货币类型一致。比如账户设置为美元账户，消费时出现人民币，Beancount 会报错。</li>
</ul>
</blockquote>
<p>账户后的金额是带有符号的，如下:</p>
<blockquote>
<ul>
<li>支出账户：一般为正数。表示花费多少钱。</li>
<li>收入账户：一般为负数。表示收入多少钱。投资收入账户可能出现正数，则表示投资亏损。</li>
<li>资产账户：可正可负。正数表示有钱存入，余额增加；负数表示有钱转出，余额减少。</li>
<li>负债账户：可正可负。正数表示还款，负债减少；负数表示借款，负债增加。</li>
</ul>
</blockquote>
<p><strong>支出为正，收入为负。</strong></p>
<h4 id="参考"><a href="#参考" class="headerlink" title="参考"></a>参考</h4><ul>
<li><p><a target="_blank" rel="noopener" href="https://erasin.wang/beancount/">beancount复式记账参考1</a></p>
</li>
<li><p><a target="_blank" rel="noopener" href="https://plaintextaccounting.org/">plain text accounting</a></p>
</li>
<li><a target="_blank" rel="noopener" href="https://zhuanlan.zhihu.com/p/87377967">beancount - SKYue</a></li>
<li><a target="_blank" rel="noopener" href="https://wzyboy.im/post/1063.html">Beancount —— 命令行复式簿记</a></li>
<li><a target="_blank" rel="noopener" href="https://yuchi.me/post/beancount-intro/">beancount 简易入门指南</a></li>
<li><a target="_blank" rel="noopener" href="https://gitpress.io/c/beancount-tutorial/">使用 beancount 记账</a></li>
<li><a target="_blank" rel="noopener" href="http://einverne.github.io/post/2019/11/double-entry-bookkeeping.html#微信账单">复式记账</a></li>
<li><a target="_blank" rel="noopener" href="https://www.dazhuanlan.com/2019/09/28/5d8e37651b173/">beancount 导入</a></li>
</ul>

    </div>

    
    
    
        

  <div class="followme">
    <p>欢迎关注我的其它发布渠道</p>

    <div class="social-list">

        <div class="social-item">
          <a target="_blank" class="social-link" href="/atom.xml">
            <span class="icon">
              <i class="fa fa-rss"></i>
            </span>

            <span class="label">RSS</span>
          </a>
        </div>
    </div>
  </div>


      <footer class="post-footer">
          <div class="post-tags">
              <a href="/tags/%E5%A4%8D%E5%BC%8F%E8%AE%B0%E8%B4%A6/" rel="tag"># 复式记账</a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/2021/06/21/rpm%E8%BD%AF%E4%BB%B6%E5%AE%89%E8%A3%85/" rel="prev" title="rpm软件安装">
      <i class="fa fa-chevron-left"></i> rpm软件安装
    </a></div>
      <div class="post-nav-item">
    <a href="/2021/06/22/vim%E4%B8%AD%E6%8F%92%E5%85%A5%E6%97%B6%E9%97%B4%E7%9A%84%E5%87%A0%E7%A7%8D%E6%96%B9%E5%BC%8F/" rel="next" title="vim中插入时间的几种方式">
      vim中插入时间的几种方式 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-4"><a class="nav-link" href="#%E5%A6%82%E4%BD%95%E5%AE%9E%E7%8E%B0%E8%B4%A2%E5%8A%A1%E8%87%AA%E7%94%B1"><span class="nav-number">1.</span> <span class="nav-text">如何实现财务自由</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#%E4%B8%BA%E4%BB%80%E4%B9%88%E8%A6%81%E5%A4%8D%E5%BC%8F%E8%AE%B0%E8%B4%A6"><span class="nav-number">2.</span> <span class="nav-text">为什么要复式记账</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#%E5%A6%82%E4%BD%95%E5%A4%8D%E5%BC%8F%E8%AE%B0%E8%B4%A6"><span class="nav-number">3.</span> <span class="nav-text">如何复式记账</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#%E4%BC%9A%E8%AE%A1%E6%81%92%E7%AD%89%E5%BC%8F"><span class="nav-number">3.1.</span> <span class="nav-text">会计恒等式</span></a></li></ol></li><li class="nav-item nav-level-4"><a class="nav-link" href="#%E4%BD%BF%E7%94%A8BeanAccount"><span class="nav-number">4.</span> <span class="nav-text">使用BeanAccount</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#%E4%BC%98%E7%82%B9"><span class="nav-number">4.1.</span> <span class="nav-text">优点</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#%E4%B8%8B%E8%BD%BD%E5%AE%89%E8%A3%85"><span class="nav-number">4.2.</span> <span class="nav-text">下载安装</span></a></li></ol></li><li class="nav-item nav-level-4"><a class="nav-link" href="#%E8%B4%A6%E6%88%B7%E7%B1%BB%E5%88%AB"><span class="nav-number">5.</span> <span class="nav-text">账户类别</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#%E5%9F%BA%E6%9C%AC%E5%80%9F%E8%B4%B7%E8%AE%B0%E8%B4%A6"><span class="nav-number">6.</span> <span class="nav-text">基本借贷记账</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#%E8%B4%A7%E5%B8%81%E8%BD%AC%E6%8D%A2"><span class="nav-number">7.</span> <span class="nav-text">货币转换</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#%E5%80%9F%E8%B4%B7%E7%AE%A1%E7%90%86"><span class="nav-number">8.</span> <span class="nav-text">借贷管理</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#%E5%AF%B9%E8%B4%A6"><span class="nav-number">9.</span> <span class="nav-text">对账</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#%E8%B5%84%E4%BA%A7%E8%B4%9F%E8%BD%BD%E8%A1%A8"><span class="nav-number">9.1.</span> <span class="nav-text">资产负载表</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#%E7%BB%93%E4%BD%99%E6%96%AD%E8%A8%80-Balance-Assertion"><span class="nav-number">9.2.</span> <span class="nav-text">结余断言(Balance Assertion)</span></a></li></ol></li><li class="nav-item nav-level-4"><a class="nav-link" href="#%E9%A1%B9%E7%9B%AE%E7%AE%A1%E7%90%86"><span class="nav-number">10.</span> <span class="nav-text">项目管理</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#%E7%89%88%E6%9C%AC%E7%AE%A1%E7%90%86"><span class="nav-number">10.1.</span> <span class="nav-text">版本管理</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#%E6%A0%87%E7%AD%BE"><span class="nav-number">10.2.</span> <span class="nav-text">标签</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#%E9%93%BE%E6%8E%A5"><span class="nav-number">10.3.</span> <span class="nav-text">链接</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#%E5%A4%9A%E6%96%87%E4%BB%B6%E7%BB%84%E7%BB%87"><span class="nav-number">10.4.</span> <span class="nav-text">多文件组织</span></a></li></ol></li><li class="nav-item nav-level-4"><a class="nav-link" href="#%E8%B4%A6%E6%9C%AC%E5%88%92%E5%88%86"><span class="nav-number">11.</span> <span class="nav-text">账本划分</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#%E5%88%9B%E5%BB%BA%E8%B4%A6%E6%88%B7%E5%92%8C%E5%85%B3%E9%97%AD%E8%B4%A6%E6%88%B7"><span class="nav-number">12.</span> <span class="nav-text">创建账户和关闭账户</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#%E4%BA%A4%E6%98%93%E6%98%8E%E7%BB%86"><span class="nav-number">13.</span> <span class="nav-text">交易明细</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#%E5%8F%82%E8%80%83"><span class="nav-number">14.</span> <span class="nav-text">参考</span></a></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">田园隐士</p>
  <div class="site-description" itemprop="description">talk is cheap, show me the code</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">347</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
        <span class="site-state-item-count">53</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
        <span class="site-state-item-count">115</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2022</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">田园隐士</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-chart-area"></i>
    </span>
    <span title="站点总字数">587k</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-coffee"></i>
    </span>
    <span title="站点阅读时长">8:53</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://muse.theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Muse</a> 强力驱动
  </div>

        
<div class="busuanzi-count">
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
    <span class="post-meta-item" id="busuanzi_container_site_uv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-user"></i>
      </span>
      <span class="site-uv" title="总访客量">
        <span id="busuanzi_value_site_uv"></span>
      </span>
    </span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item" id="busuanzi_container_site_pv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-eye"></i>
      </span>
      <span class="site-pv" title="总访问量">
        <span id="busuanzi_value_site_pv"></span>
      </span>
    </span>
</div>








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/muse.js"></script>


<script src="/js/next-boot.js"></script>




  




  
<script src="/js/local-search.js"></script>













  

  
      

<script>
  if (typeof MathJax === 'undefined') {
    window.MathJax = {
      loader: {
          load: ['[tex]/mhchem'],
        source: {
          '[tex]/amsCd': '[tex]/amscd',
          '[tex]/AMScd': '[tex]/amscd'
        }
      },
      tex: {
        inlineMath: {'[+]': [['$', '$']]},
          packages: {'[+]': ['mhchem']},
        tags: 'ams'
      },
      options: {
        renderActions: {
          findScript: [10, doc => {
            document.querySelectorAll('script[type^="math/tex"]').forEach(node => {
              const display = !!node.type.match(/; *mode=display/);
              const math = new doc.options.MathItem(node.textContent, doc.inputJax[0], display);
              const text = document.createTextNode('');
              node.parentNode.replaceChild(text, node);
              math.start = {node: text, delim: '', n: 0};
              math.end = {node: text, delim: '', n: 0};
              doc.math.push(math);
            });
          }, '', false],
          insertedScript: [200, () => {
            document.querySelectorAll('mjx-container').forEach(node => {
              let target = node.parentNode;
              if (target.nodeName.toLowerCase() === 'li') {
                target.parentNode.classList.add('has-jax');
              }
            });
          }, '', false]
        }
      }
    };
    (function () {
      var script = document.createElement('script');
      script.src = '//cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js';
      script.defer = true;
      document.head.appendChild(script);
    })();
  } else {
    MathJax.startup.document.state(0);
    MathJax.texReset();
    MathJax.typeset();
  }
</script>

    

  

</body>
</html>
